package com.jmu.content.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jmu.content.dto.PriceListPageDTO;
import com.jmu.content.mapper.PriceListMapper;
import com.jmu.content.pojo.Orders;
import com.jmu.content.pojo.PriceList;
import com.jmu.content.result.PageResult;
import com.jmu.content.service.PriceListService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fems
 * @since 2024-05-06
 */
@Service
public class PriceListServiceImpl extends ServiceImpl<PriceListMapper, PriceList> implements PriceListService {

    @Override
    public PageResult pageQuery(PriceListPageDTO dto) {
        Page<Orders> page = PageHelper.startPage(dto.getPage(), dto.getPageSize());

        LambdaQueryWrapper<PriceList> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(dto.getStationId()!=null,PriceList::getStationId,dto.getStationId())
                .orderByAsc(PriceList::getBeginTime);
        List<PriceList> list = this.list(queryWrapper);

        PageInfo pageInfo = new PageInfo(list);
        return new PageResult(page.getTotal(),pageInfo.getList());
    }
}
